<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <input type="hidden" name="rid" id="rid" value="${upOrder.rid}">
    <div class="layui-form-item">
        <label class="layui-form-label">客户名:</label>
        <div class="layui-input-block">
            <input type="hidden" name="customerId" value="${upOrder.customerId}">
            <input type="text" name="customerId1" lay-verify="required" disabled value="${upOrder.customerIds}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label ">商品名:</label>
        <div class="layui-input-block">
            <input type="hidden" name="goods" value="${upOrder.goods}">
            <input type="text" name="goods1" value="${upOrder.goodss}" autocomplete="off" class="layui-input" id="demo2">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label ">下单时间:</label>
        <div class="layui-input-block">
            <input type="text" name="orderTime" disabled value="${upOrder.orderTime}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label ">订单发货时间:</label>
        <div class="layui-input-block">
            <input type="text" name="orderGoodsTime" id="date" value="${upOrder.orderGoodsTime}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label ">客户收货时间:</label>
        <div class="layui-input-block">
            <input type="text" name="customerGetTime" id="date2" value="${upOrder.customerGetTime}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label ">订单状态:</label>
        <div class="layui-input-block">
            <select name="state" lay-verify="required" lay-search="">
                <option value="${upOrder.state}">${upOrder.state}</option>
                    <option value="已签收">已签收</option>
                <option value="未发货">未发货</option>
                <option value="开始发货">开始发货</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">备注:</label>
        <div class="layui-input-block">
            <textarea id="remarks" name="remarks" class="layui-textarea" placeholder="请输入备注"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label ">订单金额:</label>
        <div class="layui-input-block">
            <input type="text" id="orderMoney" name="orderMoney" lay-verify="required" placeholder="请输入金额" value="${upOrder.orderMoney}" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
</div>
<script src="${pageContext.request.contextPath}/layui/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath}/layui/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>

    layui.use(['form', 'tableSelect', 'laydate'], function () {
        var form = layui.form,
            layer = layui.layer,
            tableSelect = layui.tableSelect,
            laydate = layui.laydate,
            $ = layui.$;

        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#date2'
        });

        $("#remarks").val("${upOrder.remarks}");

        tableSelect.render({
            elem: '#demo2',
            searchKey: 'we',
            checkedKey: 'rid',
            table: {
                url: '${pageContext.request.contextPath}/goods_queryGoodsLimit',
                cols: [[
                    {
                        type: 'radio' }
                    ,{
                        field: 'rid',align:'center', width: 80, title: '编号', sort: true }
                    , {
                        field: 'goodsName',align:'center', width: 150, title: '商品名称' }
                    , {
                        field: 'price',align:'center', width: 80, title: '单价'}
                    , {
                        field: 'remarks',align:'center', width: 150, title: '备注' }
                ]]
            },
            done: function (elem, data) {
                var NEWJSON = []
                layui.each(data.data, function (index, item) {
                    NEWJSON.push(item.rid);
                    $("#orderMoney").val(item.price);
                })
                elem.val(NEWJSON.join(","))
            }
        })

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            $.ajax({
                url:"${pageContext.request.contextPath}/order_updateOrder",
                type:"post",
                data:"data="+JSON.stringify(data.field),
                dataType:"text",
                success:(rs)=>{
                    if(rs=="OK"){
                        layer.msg("修改成功",{icon:1,time:500},function (){
                            parent.location.reload();
                            var iframeIndex = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(iframeIndex);
                        })
                    }else{
                        layer.msg("修改失败",{icon:2,time:500})
                    }
                }
            })
        });
        return false;
    });
</script>
</body>
</html>